package com.test.languagetest;

import java.util.Set;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;

import com.pojo.Category;
import com.pojo.Product;

public class HibernateTestOneToMany {

	
	public static void main(String[] args) {
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session session = sf.openSession();
		session.beginTransaction();
		
		Category category = (Category) session.get(Category.class, 1);
		Set<Product> products = category.getProducts();
		
		for(Product p : products) {
			System.out.println(p.getName());
		}
		
		session.getTransaction().commit();
		session.close();
		sf.close();
	}
}
